#include "stdafx.h"
#include "Communication.h"

IMessage* IMessage::AddChild(IMessage* child)
{
	IMessage* tmp=m_child;
	m_child=child;
	return tmp;
}

IMessage& IMessage::operator <<(IMessage &message)
{
	IMessage* child=this;
	while(child->m_child!=NULL) child=child->m_child;
	child->m_child=&message;
	return *this;
}

BOOL IMessage::PutData(strstream* stream)
{
	if((stream!=NULL)&&(GetPartData()!=NULL))
	{
		stream->write((char*)GetPartData(),GetPartSize());
		if(m_child)
		{
			return m_child->PutData(stream);	
		}
		return TRUE;
	}
	return FALSE;
}